home *** CD-ROM | disk | FTP | other *** search
/ Light ROM Gold / Light ROM Gold.iso / arexx / standin1.rex < prev    next >
OS/2 REXX Batch file  |  1995-03-23  |  3KB  |  118 lines

  1. /*STANDIN.LWM v1.0  Supposedly constructs a simplified version of an object.*/
  2. /*                  This takes some time, so be patient.  The result is a   */
  3. /*                  "enhanced bounding box", very useful for debuggin       */
  4. /*                  motion paths.                                            */
  5. /****************************************************************************/
  6. /*  Must be launched from LWModeler Macro requestor.  Uses Booleans, so is  */
  7. /*  slow.  I highly recommend NOT using sampling values greater than 5.     */
  8. /*  But hey, it is your time.                                               */
  9. /****************************************************************************/
  10.  
  11.  
  12. libadd = addlib("LWModelerARexx.port",0)
  13. /*signal on error
  14. signal on syntax*/
  15. sample=3
  16.  
  17. sysnam="Standin Object Maker"
  18.  
  19. call addlib "rexxsupport.library", 0, -30, 0
  20. call addlib "rexxmathlib.library", 0, -30, 0
  21. call addlib "LWModelerARexx.port", 0
  22.  
  23. /* Ask user how many divisions. */
  24. call req_begin sysnam
  25. divx_r = req_addcontrol("Divisions on X axis",'N',0)
  26. divy_r = req_addcontrol("Divisions on Y axis",'N',0)
  27. divz_r = req_addcontrol("Divisions on Z axis",'N',0)
  28.  
  29. call req_setval divx_r, sample
  30. call req_setval divy_r, sample
  31. call req_setval divz_r, sample
  32.  
  33. if (~req_post()) then do
  34.                                 call req_end
  35.                                exit
  36.                                 end
  37.  
  38. divx = req_getval(divx_r)
  39. divy = req_getval(divy_r)
  40. divz = req_getval(divz_r)
  41. call REQ_END()
  42.  
  43. /* Make them integers. */
  44. divx=divx%1
  45. divy=divy%1
  46. divz=divz%1
  47.  
  48. /* Find empty layers  */
  49. empty = emptylayers()
  50. if (words(empty) < 2) then do
  51.     call notify 1,"!Need 2 empty layers","!for this operation."
  52.     exit
  53.     end
  54. boxlayer = word(empty, 1)
  55. acclayer = word(empty, 2)
  56.  
  57. /* Find active layers  */
  58. active=CURLAYER()
  59.  
  60.  
  61. /* Find upper & lower bounds */
  62. boxdata=BOUNDINGBOX()
  63. parse var boxdata n minx maxx miny maxy minz maxz 
  64.  
  65.  
  66. /* Now, make them slightly bigger, using LWM functions. */
  67. CALL SETLAYEr(boxlayer)
  68. call MAKEBOX(minx miny minz ,maxx maxy maxz )
  69. middlex=minx+((maxx-minx)/2)
  70. middley=miny+((maxy-miny)/2)
  71. middlez=minz+((maxz-minz)/2)
  72. CALL SCALE(1.01 1.01 1.01 , middlex middley middlez)
  73.  
  74. /* Retrieve slightly larger values.  */
  75. boxdata=BOUNDINGBOX()
  76. parse var boxdata n minx maxx miny maxy minz maxz 
  77. call CUT()     /* Get rid of it. */
  78.             
  79. width=maxx-minx
  80.     widthinc=width/divx
  81. heigth=maxy-miny
  82.     heigthinc=heigth/divy
  83. depth=maxz-minz
  84.     depthinc=depth/divz
  85.  
  86. lcornerx=minx    /*initializing box coordinates */
  87. lcornery=miny
  88. lcornerz=minz
  89.  
  90.  
  91. /* Start construction of boxes */
  92. total= ((divx*divy)*divz)%1    /* Make it an integer. Better ways? */
  93. DO x=1 to divx
  94.     ucornerx=lcornerx+widthinc
  95.     DO y=1 to divy
  96.         ucornery=lcornery+heigthinc
  97.         DO z=1 to divz
  98.             ucornerz=lcornerz+depthinc
  99.             CALL SETLAYER(boxlayer)
  100.             CALL MAKEBOX( lcornerx lcornery lcornerz , ucornerx ucornery ucornerz)
  101.             CALL SETBLAYER(active)
  102.             CALL BOOLEAN('INTERSECT')
  103.             box=boundingbox()  /* Should check out empty list... */
  104.             parse var box n x1 x2 y1 y2 z1 z2
  105.               CALL CUT()
  106.             CALL SETLAYER(acclayer)
  107.               CALL MAKEBOX(x1 y1 z1,x2 y2 z2)
  108.             lcornerz=ucornerz
  109.             end
  110.         lcornerz=minz
  111.         lcornery=ucornery
  112.         end
  113.     lcornery=miny
  114.     lcornerx=ucornerx
  115.     end
  116.  
  117. CALL SETLAYER(acclayer)
  118.